<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
<title>阳光灿烂</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="description" content="">
<link rel="stylesheet" href="/Public/Assets/jqweui/dist/lib/weui.min.css">
<link rel="stylesheet" href="/Public/Assets/jqweui/dist/css/jquery-weui.min.css">

<style>
#banji2_popup header h1{
    font-size: 18px;
    line-height:40px;
    color: #3cc51f;
    font-weight: 400;
    float:left;
    padding-left:15px;
  }
#banji2_popup td{border:solid #ddd; border-width:0px 1px 1px 0px;text-align:center;font-size:14px;line-height:30px;}
#banji2_popup table{border:solid #ddd; border-width:1px 0px 0px 1px;}
#banji2_popup td b{font-size:16px;padding-left:15px;}
</style>
</head>
<body ontouchstart>
<div class="weui_tab">
  <div class="weui_navbar">
    <a href="#tab1" class="weui_navbar_item weui_bar_item_on">新生</a>
    <a href="#tab2" class="weui_navbar_item">老生</a>
  </div>
  <div class="weui_tab_bd">
    <div id="tab1" class="weui_tab_bd_item weui_tab_bd_item_active">
    	<div class="weui_cells weui_cells_form">
		  <div class="weui_cell">
		    <div class="weui_cell_hd"><label class="weui_label">学生姓名</label></div>
		    <div class="weui_cell_bd weui_cell_primary">
		      <input class="weui_input" type="text" name="realname" placeholder="请输入学生姓名">
		    </div>
		  </div>
		  <div class="weui_cell">
		    <div class="weui_cell_hd"><label class="weui_label">手机号码</label></div>
		    <div class="weui_cell_bd weui_cell_primary">
		      <input class="weui_input" type="tel" name="mobile" placeholder="请输入手机号码">
		    </div>
		  </div>
		  <div class="weui_cell">
		    <div class="weui_cell_hd"><label for="" class="weui_label">出生年月</label></div>
		    <div class="weui_cell_bd weui_cell_primary">
		      <input class="weui_input" type="date" name="birthday" value="">
		    </div>
		  </div>
		  <div class="weui_cell">
		    <div class="weui_cell_hd"><label class="weui_label">校区</label></div>
		    <div class="weui_cell_bd weui_cell_primary">
		    	<input class="weui_input" id="xiaoqu" type="text" name="xiaoqu" value="">
		    </div>
		  </div>
		  <div class="weui_cell banjiDom" style="display:none;">
		    <div class="weui_cell_hd"><label class="weui_label">班级</label></div>
		    <div class="weui_cell_bd weui_cell_primary">
		    	<input class="weui_input" id="banji" type="text" name="banji" value="">
		    </div>
		  </div>
		  
		  <div class="weui_cell banjiDom" style="display:none;">
		   	<div class="weui_cell_hd"><label class="weui_label">班级详细</label></div>
		    <div class="weui_cell_bd weui_cell_primary">
		    	<input class="weui_input" id="banji2" type="text" name="banji2" readonly value="">
		    </div>
		    <div class="weui_cell_bd">
		    	<a href="javascript:show_banji_default($('#banji').val());" class="weui_btn weui_btn_mini weui_btn_primary">选择</a>
		    </div>
		  </div>
		  <div class="weui_cell banjiDom" style="display:none;">
		    <div class="weui_cell_hd"><label class="weui_label">学期</label></div>
		    <div class="weui_cell_bd weui_cell_primary">
		    	<input class="weui_input" id="xueqi" type="text" name="xueqi" value="">
		    </div>
		  </div>
		  <div class="weui_cell">
		    <div class="weui_cell_hd"><label class="weui_label">材料费</label></div>
		    <div class="weui_cell_bd weui_cell_primary">
		    	<input class="weui_input" type="text" name="cailiao" id="cailiao" readonly value="">
		    </div>
		  </div>
		  <div class="weui_cell">
		    <div class="weui_cell_hd"><label class="weui_label">合计</label></div>
		    <div class="weui_cell_bd weui_cell_primary">
		    	<input class="weui_input" type="text" name="total" id="total" readonly value="">
		    </div>
		  </div>
		</div>
		
		<div style="padding:15px;">
		  	<a href="javascript:;" class="weui_btn weui_btn_primary">申请支付</a>
		</div>
    </div>
    
    <div id="tab2" class="weui_tab_bd_item">
    	根据实际情况改一下tab1中的代码
    </div>
  </div>
</div>



<div id="banji2_popup" class="weui-popup-container">
  <div class="weui-popup-modal" style="background:#fff;">
    <header>
    	<h1 id="banji_title"></h1> 
    	<a href="javascript:;" class="weui_btn weui_btn_mini weui_btn_warn close-popup" style="float:right;margin: 6px 15px 0 0;">关闭</a>
    	<div style="clear:both"></div>
    </header>
    <div class="weui_panel weui_panel_access" style="margin-top:0;">
      <div class="weui_panel_bd"> 
        <table id="tabledata" style="width:100%;" cellpadding="0" cellspacing="0">
       		
        </table>
      </div>
    </div>
  </div>
</div>

<script src="/Public/Assets/jqweui/dist/lib/jquery-2.1.4.js"></script>
<script src="/Public/Assets/jqweui/dist/js/jquery-weui.js"></script>


<script>
//$("#banji2_popup").popup();
$(function($){
	//加载校区数据
	$.get('/home/jsondata/getxiaoqu',function(data){
		if(data.status){
			$("#xiaoqu").select("update", data.data);
		}
	});
});



$("#xiaoqu").select({
	onChange: function(d) {
	  $.get('/home/jsondata/getbanji?xiaoqu='+d.titles,function(data){
		if(data.status){
			$("#banji").select("update", data.data);
			$('.banjiDom').show();
		}
	});
   },
});

$("#banji").select({
  onChange: function(d) {
	  show_banji_default(d.titles);
	  
	  show_xueqi('','');  //学期调用测试
  },
});
$("#xueqi").select({
  onChange: function(d) {
    console.log(this, d);
  }
});
function show_xueqi(xiaoqu,banji){
	$.get('/home/jsondata/getxueqi',function(data){
		if(data.status){
			$("#xueqi").select("update", data.data);
		}
	});
}
function show_banji_default(title){
	$.get('/home/jsondata/getbanji_default?banji='+title,function(data){
		if(data.status){
			
			var result = data.data;
			$('#banji_title').html(result.header);
			var chuji = result.chuji;
			var zhongji = result.zhongji;
			var gaoji = result.gaoji;
			var html = '';
			var chuji_title = '<tr>'+
					       			'<td colspan="4" style="text-align:left;">'+
				   						'<b>初级班</b>'+
				   					'</td>'+
				   				'</tr>';
			var zhongji_title = '<tr>'+
					       			'<td colspan="4" style="text-align:left;">'+
										'<b>中级班</b>'+
									'</td>'+
								'</tr>';
			var gaoji_title = '<tr>'+
				       			'<td colspan="4" style="text-align:left;">'+
									'<b>高级班</b>'+
								'</td>'+
							'</tr>';
			var thead = '<tr>'+
			       			'<td>班级代码</td>'+
			       			'<td>适合对象</td>'+
			       			'<td>上课时间</td>'+
			       			'<td>名额</td>'+
			       		'</tr>';
			       		
			       		
			html += chuji_title + thead;
			
			for(var i = 0 ; i < chuji.length ;i++){
				html += '<tr>';
				var tmp = chuji[i];
				html += '<td>'+tmp.no+'</td>';
				html += '<td>'+tmp.obj+'</td>';
				html += '<td>'+tmp.time+'</td>';
				html += '<td>'+tmp.num+'</td>';
				html += '</tr>';
			}
			
			html += zhongji_title + thead;
			for(var i = 0 ; i < zhongji.length ;i++){
				html += '<tr>';
				var tmp = zhongji[i];
				html += '<td>'+tmp.no+'</td>';
				html += '<td>'+tmp.obj+'</td>';
				html += '<td>'+tmp.time+'</td>';
				html += '<td>'+tmp.num+'</td>';
				html += '</tr>';
			}
			
			html += gaoji_title + thead;
			for(var i = 0 ; i < gaoji.length ;i++){
				html += '<tr>';
				var tmp = gaoji[i];
				html += '<td>'+tmp.no+'</td>';
				html += '<td>'+tmp.obj+'</td>';
				html += '<td>'+tmp.time+'</td>';
				html += '<td>'+tmp.num+'</td>';
				html += '</tr>';
			}
			
			$('#tabledata').html(html);
			$("#banji2_popup").popup();
		}	
  });
}
</script>

</body>
</html>